<div class="col-md-12">

<!-- BEGIN BORDERED TABLE PORTLET-->
<div class="portlet">
	<div class="portlet-title">
		<div class="caption"> <i class="fa fa-list"></i><?= __('Danh Sách Danh Mục'); ?> </div>
		<div class="tools"></div>
	</div>
	<div class="portlet-body">
		<div class="table-toolbar">
			<div class="btn-group pull-right mb10">
				<a href="<?= $this->webroot.'admin/categories/add' ?>" class="btn btn-success"> <?= __('Thêm mới')?> <i class="fa fa-plus"></i></a>
			</div>
		</div>
		
		<div class="table-responsive clearfix">
			<table class="table table-bordered table-hover mb5">
			<thead>
			<tr>
				<th><?= __('Thứ tự');?></th>
				<th><?= __('Tên');?></th>
				<th><?= __('Danh mục con');?></th>
				<th><?= __('Trạng thái');?></th>
				<th></th>
			</tr>
			</thead>
			<tbody>
			<?php if(count($items) > 0):?>
			<?php foreach($items as $k => $v):?>
	            <?php
	                $_class = '';
	                if($v[$als]['status'] == 9) {
	                    $_class = 'danger';
	                } elseif( $v[$als]['status'] == 5) {
	                    $_class = 'warning';
	                }
	            ?>

	            <tr class="<?= $_class; ?>">
					<td style="width:70px" align="center">
						<a href="#" data-id="<?= $v[$als]['id']?>" data-mode="categories" class="change-sort tooltips tooltip-green"  data-placement="right" data-original-title="Sửa"><?= $v[$als]['sort'];?></a>
					</td>
					<td style="width:25%"><a href="<?= $this->webroot . 'admin/categories/info/' . $v[$als]['id'] ?>" class="tooltips tooltip-green" data-placement="right" data-rel="tooltip" title="" data-original-title="Xem chi tiết"><?= $v[$als]['name']?></a></td>

					<td>
						<?php if(count($v[$als]['childs']) > 0):?>
						<table class="table table-bordered table-hover mb5">
						<thead>
						<tr>
							<th><?= __('Thứ tự');?></th>
							<th><?= __('Tên');?></th>
							<th><?= __('Trạng thái');?></th>
							<th></th>
						</tr>
						</thead>

						<tbody>

						<?php foreach($v[$als]['childs'] as $child): ?>
						<?php
			                $_class = '';
			                if($child[$als]['status'] == 9) {
			                    $_class = 'danger';
			                } elseif( $child[$als]['status'] == 5) {
			                    $_class = 'warning';
			                }
			            ?>

			            <tr class="<?= $_class; ?>">
							<td style="width:70px" align="center">
								<a href="#" data-id="<?= $child[$als]['id']?>" data-mode="categories" class="change-sort tooltips tooltip-green"  data-placement="right" data-original-title="Sửa"><?= $child[$als]['sort'];?></a>
							</td>
							<td style="width:35%"><a href="<?= $this->webroot . 'admin/categories/info/' . $child[$als]['id'] ?>" class="tooltips tooltip-green" data-placement="right" data-rel="tooltip" title="" data-original-title="Xem chi tiết"><?= $child[$als]['name']?></a></td>
							<td><?= @$status[$child[$als]['status']] ?></td>
							<td align="left" style="width:80px" class="action-buttons">
							<?php echo $this->Form->create($als, array('url' => $this->webroot . 'admin/categories/changStatus' )); ?>
								<?php echo $this->Form->hidden('id');  ?>
								<?php echo $this->Form->hidden('status');  ?>
								
								<a href="<?= $this->webroot . 'admin/categories/add/' . $child[$als]['id'] ?>" class="tooltips tooltip-green" data-placement="top" title="" data-original-title="Sửa"><i class="fa fa-edit text-green"></i></a>
								
								<?php if($child[$als]['status'] == 5):?>
									<a href="#" data-id="<?= $child[$als]['id'] ?>" data-status="4" data-confrim="<?= __('Bạn có chắn chắn muốn bỏ khóa danh mục này không ?')?>" class="tooltips tooltip-red remove" data-placement="top" title="" data-original-title="Bỏ khóa"><i class="fa fa-unlock text-red"></i></a>
								<?php else: ?>
									<a href="#" data-id="<?= $child[$als]['id'] ?>" data-status="5" data-confrim="<?= __('Bạn có chắn chắn muốn khóa danh mục này không ?')?>" class="tooltips tooltip-red remove" data-placement="top" title="" data-original-title="Khóa"><i class="fa fa-lock text-red"></i></a>
								<?php endif;?>
								
								<?php if($child[$als]['fix'] == 0): ?>									
									<a href="#" data-id="<?= $child[$als]['id'] ?>" data-status="9" data-confrim="<?= __('Bạn có chắn chắn muốn xóa danh mục này không ?')?>" class="tooltips tooltip-red remove" data-placement="top" title="" data-original-title="Xóa"><i class="fa fa-trash-o text-red"></i></a>
								<?php endif;?>
							<?php echo $this->Form->end(); ?>
							</td>
						</tr>
						<?php endforeach; ?>
						</tbody>
						</table>
						<?php endif; ?>
					</td>

					<td><?= @$status[$v[$als]['status']] ?></td>
					<td align="center" class="action-buttons">
						<?php echo $this->Form->create($als, array('url' => $this->webroot . 'admin/categories/changStatus' )); ?>
						<?php echo $this->Form->hidden('id');  ?>
						<?php echo $this->Form->hidden('status');  ?>
						<a href="<?= $this->webroot . 'admin/categories/add/' . $v[$als]['id'] ?>" class="tooltips tooltip-green" data-placement="top" title="" data-original-title="Sửa"><i class="fa fa-edit text-green"></i></a>
						<?php if($v[$als]['status'] == 5):?>
						<a href="#" data-id="<?= $v[$als]['id'] ?>" data-status="4" data-confrim="<?= __('Bạn có chắn chắn muốn bỏ khóa danh mục này không ?')?>" class="tooltips tooltip-red remove" data-placement="top" title="" data-original-title="Bỏ khóa"><i class="fa fa-unlock text-red"></i></a>
						<?php else: ?>
						<a href="#" data-id="<?= $v[$als]['id'] ?>" data-status="5" data-confrim="<?= __('Bạn có chắn chắn muốn khóa danh mục này không ?')?>" class="tooltips tooltip-red remove" data-placement="top" title="" data-original-title="Khóa"><i class="fa fa-lock text-red"></i></a>
						<?php endif;?>
						<?php echo $this->Form->end(); ?>
					</td>
				</tr>
			<?php endforeach; endif;?>
			</tbody>
			</table>

			<?php $params = $this->Paginator->params(); if($params['pageCount'] > 1) :?>
				<div class="clearfix"></div>
				<?php echo $this->element('paging'); ?>
			<?php endif; ?>
		</div>
	</div>
</div>

<!-- END BORDERED TABLE PORTLET-->
</div>
